<template>
<!-- 理赔计算 医疗保险 -->
<div >
<div>
<el-form :inline="true"  class="demo-form-inline">
  <el-form-item label="当日美元汇率">
    <el-input v-model="huilv" placeholder="当日美元汇率"></el-input>
  </el-form-item>
 
</el-form>
</div>
 <el-table
    :data="list"
    border
    style="width: 100%"
    height="400"
     v-loading="loading"
     element-loading-text="拼命计算中,请稍等">
    <el-table-column      
      prop="REPORTINFORMATION.REPORTINFORMATION_ID"
      label="报案号"
      width="200">
    </el-table-column>   
    <el-table-column
      prop="REPORTINFORMATION.REPORTINFORMATION_WAY"
      label="报案方式"
      width="100">
    </el-table-column>
    <el-table-column
      prop="REPORTINFORMATION.REPORTINFORMATION_TIME"
      label="报案时间"
      width="200">
    </el-table-column>
    <el-table-column
      prop="REPORTINFORMATION.REPORTINFORMATION_USERNAME"
      label="报案人姓名"
      width="150">
    </el-table-column>  
     <el-table-column
      prop="REPORTINFORMATION.REPORTINFORMATION_TEL"
      label="报案人电话"
      width="200">
    </el-table-column> 
     <el-table-column
      prop="REPORTINFORMATION.REPORTINFORMATION_RELATION"
      label="报案人与保险人关系"
      width="200">
    </el-table-column> 
    
    <el-table-column     
      label="操作"
      width="150">
      <template scope="scope">      
        <el-button type="text" size="media" @click="gocheck(scope.row.BILL_ID,scope.row.BILL_STATE)">
        <i class="el-icon-edit" v-if="scope.row.BILL_STATE=='审核通过'"> 计算</i>
      <i class="el-icon-edit" v-else> 查看结果</i>
        </el-button>
      </template>
</el-table-column>
</el-table>
<div class="block">
    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage1" :page-size="10" layout="total, prev, pager, next" :total="pagecount">
    </el-pagination>
</div>
</div>
</template>
<script>
    export default {

        data() {
            return {
                loading: false,
                list: [],
                currentPage1: 1,
                pagecount: 0,
                REPORTINFORMATION_ID: "",
                REPORTINFORMATION_IDENTITY: "",
                REPORTINFORMATION_RELATION: "",
                REPORTINFORMATION_USERNAME: "",
                REPORTINFORMATION_TIME: "",
                REPORTINFORMATION_WAY: "",
                REPORTINFORMATION_TEL: "",
                REPORTINFORMATION_EMAIL: "",
                huilv: ""
            }
        },
        methods: {
            handleSizeChange(val) {
               
            },
            handleCurrentChange(val) {
                this.currentPage = val;
              
                this.$http.get("BILL?pagesize=10&type=审核通过&page=" + val).then(response => {
                    var data = response.body;
                    if (data.code == 1) {
                        this.tableData3 = data.result;
                    } else {
                        this.$notify.error({
                            title: '失败',
                            message: '数据获取失败'
                        });
                    }
                }, response => {
                    this.$notify.error({
                        title: '网络错误',
                        message: '网络错误'
                    });
                    this.loding = false;
                });
            },
            gocheck(id, type) {
                if (type == "审核通过") {
                    this.loading = true;
                    if (this.huilv == "") {
                        this.$notify.error({
                            title: '请输入汇率',
                            message: '请输入汇率'
                        })
                        this.loading = false;
                        return;
                    }
                    this.$http.get("Bill/sum?id=" + id + "&huilv=" + this.huilv).then(response => {
                        var data = response.body;
                        if (data.code == 1) {
                            this.$notify.success({
                                title: '成功',
                                message: '计算成功'
                            });
                            this.getdata();
                            this.loading = false;
                        } else {
                            this.getdata();
                            this.$notify.error({
                                title: '失败',
                                message: '计算失败'
                            })
                            this.loding = false;
                        }
                    }, response => {
                        this.$notify.error({
                            title: '网络错误',
                            message: '网络错误'
                        });
                        this.loding = false;
                    });

                } else {
                    this.$router.push({
                        name: 'lipeitaskResultMedical',
                        query: {
                            id: id

                        }
                    })
                }
            },
            getdata() {
                this.$http.get("BILL?pagesize=10&page=1&type=审核通过").then(response => {
                    var data = response.body;
                    if (data.code == 1) {
                        this.list = data.result;
                        this.pagecount = data.pagecount;
                    } else {
                        this.$notify.error({
                            title: '失败',
                            message: '数据获取失败'
                        });
                    }
                }, response => {
                    this.$notify.error({
                        title: '网络错误',
                        message: '网络错误'
                    });
                    this.loding = false;
                });
            }
        },
        activated() {
            this.getdata();
        }
    }
</script>
<style>

</style>